package com.ftw.commons.log

import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.FormatStrategy
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy


/**
 * 描    述：
 * 作    者：fantianwen
 * 时    间：2019/2/19  11:04 AM
 */

object LogUtils {

    fun init(isDebug: Boolean) {

        val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder()
            .showThreadInfo(false) // (Optional) Whether to show thread info or not. Default true
            .methodCount(0) // (Optional) How many method line to show. Default 2
            .methodOffset(7) // (Optional) Hides internal method calls up to offset. Default 5
            .showThreadInfo(false)
            .tag("Midu-Log") // (Optional) Global tag for every log. Default PRETTY_LOGGER
            .build()

        Logger.addLogAdapter(object : AndroidLogAdapter(formatStrategy) {
            override fun isLoggable(priority: Int, tag: String?): Boolean {
                return isDebug
            }
        })


    }

    fun v(message: String) {
        Logger.v(message)
    }

    fun i(message: String) {
        Logger.i(message)
    }

    fun w(message: String) {
        Logger.w(message)
    }

    fun e(message: String) {
        Logger.e(message)
    }

    fun d(message: String) {
        Logger.d(message)


    }


}